// (c) 2008 Kickstone Technology Ltd

#pragma once

class CIEWindow;

class CRebarHandler  : public CWindowImpl<CRebarHandler>{
public:
	CRebarHandler(HWND hWndToolbar, CIEWindow *ieWindow);
	~CRebarHandler();

	BEGIN_MSG_MAP(CRebarHandler)
		NOTIFY_CODE_HANDLER(TBN_DROPDOWN, onNotifyDropDown)
		NOTIFY_CODE_HANDLER(TBN_TOOLBARCHANGE, onNotifyToolbarChange)
		NOTIFY_CODE_HANDLER(NM_CUSTOMDRAW, onNotifyCustomDraw)
		NOTIFY_CODE_HANDLER(TBN_ENDADJUST, onNotifyEndAdjust)
		MESSAGE_HANDLER(WM_SETREDRAW, onSetRedraw)
	END_MSG_MAP()

	// message handlers
	LRESULT onNotifyDropDown(WPARAM wParam, LPNMHDR pNMHDR, BOOL& bHandled); 
	LRESULT onNotifyToolbarChange(WPARAM wParam, LPNMHDR pNMHDR, BOOL& bHandled);
	LRESULT onNotifyCustomDraw(WPARAM wParam, LPNMHDR pNMHDR, BOOL& bHandled);
	LRESULT onNotifyEndAdjust(WPARAM wParam, LPNMHDR pNMHDR, BOOL& bHandled);
	LRESULT onSetRedraw(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);

	// manage the subclassing of the IE rebar
	void subclass();
	void unsubclass();

	void handleSettings();

private:
	// handles to the various things
	HWND m_hWnd;
	HWND m_hWndToolbar, m_hWndRebar, m_hWndTooltip;
	HMENU m_hMenu;

	int m_buttonID;
	int m_ieVer;
	
	CIEWindow *m_ieWindow;

	// toolbar finding functions
	void scanForToolbarSlow();
	void getRebarHWND();
	void setButtonMenu();
	bool findButton(HWND hWndToolbar);
	void scanTooltips();
	void findToolbarIE6();
	bool getRebarHWNDIE6Quick();
};
